package com.zmn.oms.model.vo.work;

import com.zmn.common.constant.GlobalConsts;
import com.zmn.common.constant.StatusConsts;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 类描述：操作权限
 *
 * @author lujia
 * @date 2018/12/03 14:44
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class OperatePermissionVO {

    /**
     * 操作Id
     */
    private Integer id;

    /**
     *  操作类型名
     */
    private String name;

    /**
     * 是否能操作
     */
    private Boolean canOperate;

    /**
     * 是否隐藏
     */
    private Boolean hidden;

    /**
     * code
     */
    private Integer code;

    /**
     * 提示信息
     */
    private String msg;

    /**
     * 默认成功可操作
     */
    public static OperatePermissionVO success(){
        return new OperatePermissionVO(null, null, true, false,
                StatusConsts.STATUS_SUCCESS, GlobalConsts.SUCCESS_MSG);
    }

    /**
     * 成功可操作
     */
    public static OperatePermissionVO success(String msg){
        return new OperatePermissionVO(null, null, true, false,
                StatusConsts.STATUS_ERROR, msg);
    }

    /**
     * 默认失败不可操作
     */
    public static OperatePermissionVO fail(){
        return new OperatePermissionVO(null, null, false, false,
                StatusConsts.STATUS_ERROR, GlobalConsts.FAILD_MSG);
    }

    /**
     * 失败不可操作
     */
    public static OperatePermissionVO fail(String msg){
        return new OperatePermissionVO(null, null, false, false,
                StatusConsts.STATUS_ERROR, msg);
    }

    /**
     * 隐藏
     */
    public static OperatePermissionVO fail(boolean hidden){
        return new OperatePermissionVO(null, null, false, hidden,
                StatusConsts.STATUS_ERROR, GlobalConsts.FAILD_MSG);
    }

    /**
     * 隐藏
     */
    public static OperatePermissionVO fail(boolean hidden, String msg){
        return new OperatePermissionVO(null, null, false, hidden,
                StatusConsts.STATUS_ERROR, msg);
    }
}
